public static AMessage retrieveMessage(String aMessage) {
  AMessage message = null;
  String[] information = aMessage.split(AMessage.messageSplit);
  MessageType type = MessageType.decode(information[0]);
  String theMessage = information[1];
  
  switch(type) {
    case MEASUREMENT:
      message = new MeasureMessage();
      message.messageType = type;
      ((AMessage)message).retrieveMyMessage(theMessage);
      break;
    case EMIT:
      message = new EmitMessage();
      message.messageType = type;
      ((AMessage)message).retrieveMyMessage(theMessage);
      break;
    ...
    default:
      message = new NotUnderstoodMessage();
      message.messageType = type;
      ((AMessage)message).retrieveMyMessage(theMessage);
  }
  return message;
}